import type { ItemType } from 'ant-design-vue';
import { renderIcon } from '@/utils/icon-utils';

export function buildMenuTree(menus: MenuApiResp.Menu[]): ItemType[] {
  return menus
    .filter(menu => !menu.isHidden)
    .map(menu => {
      return {
        key: menu.id,
        title: menu.name,
        label: menu.name,
        icon: renderIcon(menu.icon),
        children: menu.children?.length ? buildMenuTree(menu.children) : undefined,
      };
    });
}
